﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HanGu.Entity;

namespace Hangu.WebClient.Controllers
{
    public class RostrumController : BaseController
    {
        //
        // GET: /Rostrum /

        public ActionResult Index()
        {
            IninFlashXml(3);
            VBemaLecturerInfo tempBemaLecturer = null;
            List<VBemaLecturerInfo> tempBemaLecturers = null;
            ViewData["PhilosopherBema"] = tempBemaLecturer = servicePhilosopherBema.GetForIndex();//正在进行
            SearchParma.Pagination.PageSize = 4;
            SearchParma.ClassType = 2;
            tempBemaLecturers = servicePhilosopherBema.GetAllAndLecturer(SearchParma);
            if (tempBemaLecturer != null && tempBemaLecturers != null)
            {
                tempBemaLecturers = tempBemaLecturers.Where(c => !c.IsIndex.HasValue || c.IsIndex == false).ToList();
                ViewData["PlanBemas"] = tempBemaLecturers;
            }
            SearchParma.ClassType = 0;
            SearchParma.Pagination.PageSize = HelperCommon.RostrumIsTop;
            ViewData["BemasIsTops"] = servicePhilosopherBema.GetForTop(SearchParma);//精彩回顾
            SearchParma.Pagination.PageSize = HelperCommon.LecturerIsTop;
            ViewData["Lecturers"] = servicePhilosopherBema.GetAllAndLecturer(SearchParma);

            return View();
        }

        public ActionResult List()
        {
            IninFlashXml(3);

            ViewData["pageform"] = "RostrumspagerForm";
            SearchParma.Pagination.PageSize = HelperCommon.RostrumPageSize;
            var models = servicePhilosopherBema.GetAllAndLecturer(SearchParma);//精彩回顾
            return View(models);
        }
        public ActionResult Plans()
        {
            IninFlashXml(3);

            ViewData["pageform"] = "RostrumspagerForm";
            SearchParma.Pagination.PageSize = HelperCommon.RostrumPageSize;
            SearchParma.ClassType = 2;//讲坛安排
            var models = servicePhilosopherBema.GetAllAndLecturer(SearchParma);
            return View(models);
        }
        //
        // GET: /Rostrum /Details/5
        
        public ActionResult Detail(int id)
        {
            if (Session["Member"] == null)
            {
                return RedirectToAction("Login","Vip");
            }
            ViewData["pageform"] = "RostrumspagerForm";
            var model = servicePhilosopherBema.GetAndLecturerByID(id);
            ViewData["BemaCatalog"] = new SelectList(serviceDict.GetByGroupName("BemaCatalog"), "GenerateKey", "Value");
            if (model != null)
            {
                SearchParma.Pagination.PageSize = 6;
                SearchParma.Lectcher = model.Lecturer;
                ViewData["RelativeRostrum"] = servicePhilosopherBema.GetAllAndLecturer(SearchParma);
            }

            return View(model);
        }

        public ActionResult Content(int id)
        {
            ViewData["pageform"] = "RostrumspagerForm";
            ViewData["BemaCatalog"] = new SelectList(serviceDict.GetByGroupName("BemaCatalog"), "GenerateKey", "Value");
            var model = servicePhilosopherBema.GetAndLecturerByID(id);
            return View(model);
        }

        //
        // GET: /Rostrum /Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /Rostrum /Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Rostrum /Edit/5

        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /Rostrum /Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Rostrum /Delete/5

        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /Rostrum /Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
